package com.smh.a12WaitThread1;

public class Cook extends Thread {
    @Override
    public void run() {
        while (true) {
            synchronized (Desk.lock) {
                if (Desk.count == 0) {
                    break;
                }
                if (Desk.foodFlag == 0) {
                    Desk.foodFlag = 1;
                    System.out.println("又做了一碗");
                    Desk.lock.notifyAll();//唤醒顾客
                } else {
                    try {
                        Desk.lock.wait();//等待
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    }
}
